package com.yfuxdeer.youchat.utils;

import android.app.Activity;
import android.content.pm.PackageManager;
import android.widget.Toast;

import androidx.core.app.ActivityCompat;
import androidx.core.content.ContextCompat;

public class PermissionRequester {
    public static void requestPermission(Activity activity, String[] permissions) {
        for (String permission : permissions) {
            if (ContextCompat.checkSelfPermission(activity, permission) != PackageManager.PERMISSION_GRANTED) {
                Toast.makeText(activity, "申请权限", Toast.LENGTH_SHORT).show();
                ActivityCompat.requestPermissions(activity, permissions, 100);
                break;
            }
        }
    }
}
